//
//  WCNPICCPreserveRecordAddCell.m
//  WCN
//
//  Created by 陈武琦 on 16/3/29.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNPICCPreserveRecordAddCell.h"
#import "Masonry.h"




@implementation WCNPICCPreserveRecordAddCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUp];
        [self setConstraints];
        //self.contentView.backgroundColor = [UIColor orangeColor];
    }

    return self;
}

- (void)setUp {

    _titleLabel = [UILabel new];
    _titleLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_titleLabel];

    _contentLabel = [UILabel new];
    _contentLabel.font = [UIFont systemFontOfSize:15];
    _contentLabel.numberOfLines = 0;
    _contentLabel.textColor = kTxtColor;
    _contentLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_contentLabel];
//    _titleLabel.backgroundColor = [UIColor blueColor];
//    _contentLabel.backgroundColor = [UIColor redColor];
    
    _rightIcon = [[UIImageView alloc] init];
    [_rightIcon setImage:[UIImage imageNamed:@"Arrow_Right"]];
    [self.contentView addSubview:_rightIcon];
    _rightIcon.contentMode = UIViewContentModeScaleAspectFill;
    
    [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired
                               forAxis:0];
    [_titleLabel setContentCompressionResistancePriority:UILayoutPriorityRequired
                                             forAxis:0];
//    [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired
//                                     forAxis:1];
//    [_titleLabel setContentCompressionResistancePriority:UILayoutPriorityRequired
//                                                   forAxis:1];
    
    [_contentLabel setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:1];
    [_contentLabel setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:1];

    
}



- (void)setConstraints {
    defineWeakSelf;
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakSelf.contentView.mas_left).offset(15);
        make.right.equalTo(_contentLabel.mas_left).offset(-5);
        make.top.equalTo(weakSelf.contentView.mas_top);
        make.height.equalTo(@46);
    }];

    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(_rightIcon.mas_left).offset(-5);
        make.top.equalTo(weakSelf.contentView.mas_top).offset(10);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-10);
    }];

    [_rightIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-15);
        make.size.mas_equalTo(CGSizeMake(13, 13));
        make.centerY.equalTo(_titleLabel.mas_centerY);
    }];

}



- (void)setContentText:(NSString *)contentText {

    _contentText = contentText;
    
    if ([_contentText isKindOfClass:[NSNumber class]]) {
        self.contentLabel.text = [NSString stringWithFormat:@"%@",_contentText];
    }else {
    
        self.contentLabel.text = _contentText;
    
    }
}



//- (void)setIs_warmDisplay:(BOOL)is_warmDisplay {
//
//    defineWeakSelf;
//    _is_warmDisplay = is_warmDisplay;
//    if (_is_warmDisplay) {
//        if ([[self.warmLabel superview] isEqual:self.contentView]) {
//            return;
//        }
//        [self addNextLineLabel];
//    }else {
//        [_rightIcon setImage:[UIImage imageNamed:@"Arrow_Right"]];
//        [_contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//            
//            make.right.equalTo(_rightIcon.mas_left).offset(-5);
//            make.top.equalTo(weakSelf.contentView.mas_top).offset(10);
//            make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-10);
//        }];
//
//        [self.warmLabel removeFromSuperview];
//        [self.warmContentLabel removeFromSuperview];
//        [self.unitLabel removeFromSuperview];
//    }
//}
//
//
//- (void)addNextLineLabel {
//    
//    [_rightIcon setImage:[UIImage imageNamed:@"Arrow_Down"]];
//    UILabel *warmLabel = [UILabel new];
//    //warmLabel.backgroundColor = [UIColor blackColor];
//    warmLabel.text = @"发热";
//    warmLabel.font = [UIFont systemFontOfSize:16];
//    
//    UILabel *warmContentLabel = [UILabel new];
//    warmContentLabel.textColor = kTxtColor;
//    warmContentLabel.font = [UIFont systemFontOfSize:15];
//    warmContentLabel.textAlignment = NSTextAlignmentRight;
//    
//    UILabel *unitLabel = [UILabel new];
//    unitLabel.text = @"°C";
//    unitLabel.textColor = kTxtColor;
//    [self.contentView addSubview:warmLabel];
//    [self.contentView addSubview:warmContentLabel];
//    [self.contentView addSubview:unitLabel];
//    
//    _warmLabel = warmLabel;
//    _warmContentLabel = warmContentLabel;
//    _unitLabel = unitLabel;
//   
//    defineWeakSelf;
//    [_contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(_rightIcon.mas_left).offset(-5);
//        make.top.equalTo(weakSelf.contentView.mas_top).offset(10);
//        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-35);
//    }];
//
//    [warmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(weakSelf.contentView.mas_left).offset(15);
//        //make.top.equalTo(_contentLabel.mas_bottom).offset(10);
//        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-10);
//        make.height.equalTo(@15);
//        
//    }];
//   
//    [warmContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(warmLabel.mas_right).offset(5);
//        make.right.equalTo(unitLabel.mas_left).offset(-5);
//        make.top.equalTo(warmLabel.mas_top);
//        make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-10);
//        
//    }];
//    
//    
//    [unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.right.equalTo(weakSelf.contentView.mas_right).offset(-5);
//        make.centerY.equalTo(warmContentLabel.mas_centerY);
//        make.size.mas_equalTo(CGSizeMake(20, 20));
//        
//    }];
//}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
